<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fnx" uri="http://java.sun.com/jsp/jstl/functionsx"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <script type="text/javascript">
      $(function() {
        $("#validForm").validate();
        $("input[name='name']").focus();
        $('#myTabs a').click(function (e) {
          e.preventDefault()

          if($(e.target).attr("name")=='bignew'){
            $("#validForm").attr("action","/cmscp/core/flash_big/infosave.do");
            $("#tab").val("profile");
          }
          if($(e.target).attr("name")=='flashnew'){
            $("#validForm").attr("action","/cmscp/core/flash_big/flashNewSave.do");
            $("#tab").val("home");
          }

          $(this).tab('show')
        })
        if('${tab}'=="profile"){
            $("#profile").addClass("active").siblings().removeClass("active");
            $("#big").addClass("active").siblings().removeClass("active");
            $("#validForm").attr("action","/cmscp/core/flash_big/infosave.do");
        }
        <shiro:lacksPermission name="core:flash_big:flash">
        $("#profile").addClass("active").siblings().removeClass("active");
        $("#big").addClass("active").siblings().removeClass("active");
        $("#validForm").attr("action","/cmscp/core/flash_big/infosave.do");
        </shiro:lacksPermission>
      });
      function confirmDelete() {
        return confirm("<s:message code='confirmDelete'/>");
      }

      function chooseInfo() {
        var connInfoid=$("#connInfoid").val();
        var title=$("#title").val();

        location.href='/cmscp/core/flash_big/chooseinfolist.do?tab=profile&returnUrl=core/flash_big_news/node_choose_info&connInfoid='+connInfoid+'&title='+title;

      }
      function  clearInfo(){
        $("#connInfoid").val("");
        $("#conTitle").val("");
      }


    </script>
</head>
<body class="skin-blue content-body" id="load">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1>快讯/重磅新闻</h1>
    <shiro:hasPermission name="core:sinatv:generationTv01">
    <button class="btn btn-default" style="margin-top: 10px;" type="button" onclick="$('#load').showLoading();location.href='/cmscp/core/generation/generationDataByNode.do?returnUrl=/cmscp/core/flash_big/flash_big_list&queryNodeId=${queryNodeId}';">生成</button>
    </shiro:hasPermission>

</div>
<div class="content">
    <div class="box box-primary">
        <form class="form-horizontal" id="validForm" action="/cmscp/core/flash_big/flashNewSave.do" method="post">
            <tags:search_params/>
            <%--<f:hidden name="oid" value="${bean.id}"/>--%>
            <%--<f:hidden name="position" value="${position}"/>--%>
            <input type="hidden" id="redirect" name="redirect" value="edit"/>
            <div class="box-header with-border">

            </div>
            <div class="box-body">
                <ul class="nav nav-tabs" role="tablist" id="myTabs" style="margin-bottom: 25px;">
                    <shiro:hasPermission name="core:flash_big:flash">
                    <li role="presentation" class="active"><a href="#home" name="flashnew" aria-controls="home" role="tab" data-toggle="tab">快讯新闻设置</a></li>
                    </shiro:hasPermission>
                    <li role="presentation" id="big"><a href="#profile" aria-controls="profile" name="bignew" role="tab" data-toggle="tab">重磅新闻</a></li>
                </ul>

                <!-- Tab panes -->
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" id="home">
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">快讯来源</label>
                                    <label class="col-sm-2 control-label"></label>
                                    <div class="col-sm-8">
                                        <label>时讯</label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">更新频率</label>
                                    <div class="col-sm-8">
                                        <select class="form-control" name="cronExpression" id="cronExpression">
                                            <f:option value="0 */5 * * * ?"
                                                      selected="${job.cronExpression}"> 每5分钟更新</f:option>
                                            <f:option value="0 */10 * * * ?"
                                                      selected="${job.cronExpression}"> 每10分钟更新</f:option>
                                            <f:option value="0 */30 * * * ?"
                                                      selected="${job.cronExpression}"> 每30分钟更新</f:option>
                                            <f:option value="0 0 * * * ?"
                                                      selected="${job.cronExpression}"> 每1小时更新</f:option>
                                            <f:option value="0 0 */3 * * ?"
                                                      selected="${job.cronExpression}"> 每3小时更新</f:option>
                                            <f:option value="0 0 */12 * * ?"
                                                      selected="${job.cronExpression}"> 每12小时更新</f:option>
                                        </select>

                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="box-footer">
                            <button class="btn btn-primary" type="submit"><s:message code="save"/></button>
                        </div>
                    </div>
                    <div role="tabpanel" class="tab-pane" id="profile">
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">内容编辑</label>
                                    <label class="col-sm-2 control-label"></label>
                                    <div class="col-sm-8">
                                        <f:text id="title" name="title" value="${title}" class="form-control required" maxlength="150"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">关联文章（可选）</label>
                                    <div class="col-sm-8">
                                        <button class="btn btn-primary" onclick="chooseInfo()"
                                                type="button">选择文章</button>
                                        <button class="btn btn-primary" onclick="clearInfo()"
                                                type="button">清空文章</button>
                                        <f:text id="conTitle" value="${connInfo.detail.title}" disabled="true" class="form-control"/>
                                        <f:hidden id="connInfoid" name="connInfoid" value="${connInfo.id}"/>
                                        <f:hidden id="tab" name="tab" value="${tab}"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="box-footer">
                            <button class="btn btn-primary" type="submit">立即发布</button>
                            <shiro:hasPermission name="core:flash_big:cancelBigPublish">
                            <button class="btn btn-primary" type="button"  onclick="location.href='/cmscp/core/flash_big/cancelBigPublish.do?tab=profile'">取消发布</button>
                            </shiro:hasPermission>
                        </div>
                    </div>
                </div>

            </div>
        </form>
    </div>
</div>
</body>
</html>